using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using MAPDavy.Entities;

namespace MAPDavy.Repository.Mapping
{
	public class ParameterReportMap : EntityTypeConfiguration<ParameterReport>
	{
		public ParameterReportMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);

			// Properties
			this.Property(t => t.Name)
				.IsRequired()
				.HasMaxLength(255);
				
			this.Property(t => t.Value)
				.IsRequired()
				.HasMaxLength(255);
				
			this.Property(t => t.DataType)
				.IsRequired()
				.HasMaxLength(50);
				
			// Table & Column Mappings
			this.ToTable("ParameterReport");
			this.Property(t => t.Id).HasColumnName("Id");
			this.Property(t => t.Name).HasColumnName("Name");
			this.Property(t => t.Value).HasColumnName("Value");
			this.Property(t => t.DataType).HasColumnName("DataType");
			this.Property(t => t.ReportId).HasColumnName("ReportId");

			// Relationships
			this.HasRequired(t => t.Report)
				.WithMany(t => t.ParameterReports)
				.HasForeignKey(d => d.ReportId);
				
		}
	}
}

